﻿// (c) Copyright Webber-Cross Software Ltd.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.ComponentModel;

namespace WebberCross.Obelisk.MVVMDemo.ViewModel
{
    public abstract class TombstonePersistentBase : IPersistent, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Occurs after a class has been instantiated for the first time
        /// </summary>
        public virtual void OnLaunched()
        {

        }

        /// <summary>
        /// Occurs after an instance has been rehydrated after an activation
        /// </summary>
        public virtual void OnActivated(bool preserved)
        {

        }

        /// <summary>
        /// Occurs before an instance is dehydrated the tombstoned
        /// </summary>
        public virtual void OnDeactivated()
        {

        }

        /// <summary>
        /// Occurs when the application is closing
        /// </summary>
        public virtual void OnClosing()
        {

        }

        protected void RaisePropertyChanged(string propName)
        {
            if(this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }
    }
}
